package com.feiyuan.book.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.feiyuan.book.entity.BookListEntity;
import com.feiyuan.book.service.BookListService;
import com.feiyuan.common.utils.PageUtils;
import com.feiyuan.common.utils.R;



/**
 * 书籍列表
 *
 * @author Xupf
 * @email xupengfei131276@126.com
 * @date 2024-10-10 20:44:22
 */
@RestController
@RequestMapping("book/booklist")
public class BookListController {
    @Autowired
    private BookListService bookListService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("book:booklist:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bookListService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("book:booklist:info")
    public R info(@PathVariable("id") Long id){
		BookListEntity bookList = bookListService.getById(id);

        return R.ok().put("bookList", bookList);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("book:booklist:save")
    public R save(@RequestBody BookListEntity bookList){
		bookListService.save(bookList);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("book:booklist:update")
    public R update(@RequestBody BookListEntity bookList){
		bookListService.updateById(bookList);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("book:booklist:delete")
    public R delete(@RequestBody Long[] ids){
		bookListService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
